Elisp Boolean

Table of Contents

There’s no boolean type in elisp. nil, 'nil, and empty list are false, anything else is true. By convention, t is used for true.

There’re also boolean functions, and, or, not. All of them can accept any number of arguments.

1. Equality Test

We can use equal function to test both datatype and value; eq for checking if they are same object; string-equal for comparing strings

2. Functions whose Names End in p

Functions whose names that end with p means that they returns boolean. p stands for predicate. For examples,

(boundp SYMBOL)
returns true if SYMBOL’s value is not void.
(buffer-modified-p &optional BUFFER)
returns non-nil if BUFFER was modified since its file was last read or saved. By default, BUFFER refers to the current buffer. If BUFFER was autosaved since it was last modified, it returns the symbol autosaved.
(consp OBJECT)
return true if OBJECT is a cons cell.
(fboundp SYMBOL)
returns true if SYMBOL has function definition
(featurep FEATURE &optional SUBFEATURE)
returns true if FEATURE is present in this Emacs.
(file-directory-p FILENAME)
returns true if FILENAME names an existing directory; nil if it does not name a directory, or cannot determine.
(file-exists-p FILENAME)
returns true if it exists, regardless of whether we can read.
(file-readable-p FILENAME)
returns true if it exists and is readable.
(functionp OBJECT), integerp, listp, ~numberp, stringp, symbolp, vectorp, zerop
returns true if OBJECT is a function, or integer, or list, ……

Date: 2026-07-21 Tue